package thread;

import java.util.List;
import java.util.concurrent.*;

/**
 * Created by ZhuQianli on 2018/1/16.
 */
public class ThreadPoolExecutorTest {

    public static void main(String[] args){

        ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(3, 3, 60L, TimeUnit.SECONDS, new LinkedBlockingDeque<>());

        poolExecutor.execute(() -> {
            System.out.println(1);
        });
        poolExecutor.execute(() -> {
            System.out.println(2);
        });
        poolExecutor.execute(() -> {
            System.out.println(3);
        });

    }

    static class CustomExecutor extends AbstractExecutorService {

        @Override
        public void shutdown() {

        }

        @Override
        public List<Runnable> shutdownNow() {
            return null;
        }

        @Override
        public boolean isShutdown() {
            return false;
        }

        @Override
        public boolean isTerminated() {
            return false;
        }

        @Override
        public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
            return false;
        }

        @Override
        public void execute(Runnable command) {

        }
    }

    static class TestJob implements Runnable {

        int i;

        public TestJob(int i) {
            this.i = i;
        }

        @Override
        public void run() {
            try {
                Thread.sleep(3000L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("success " + i);
        }
    }

}
